﻿using System;
using System.Collections.Generic;
using System.Text;
using Torch.WL.Business.Interface;
using Torch.FrameWork.Utility;
using Torch.WL.Business.CleanChina;
using Torch.WL.Entity.CleanChina;

namespace Torch.WL.Business
{
    public class Company1Provider : BaseProvider<Company1Provider.RequestDataInfo>, IDataProvider
    {
        public Company1Provider(string _jsonInfo) : base(_jsonInfo)
        {

        }

        public IMessageInfo Do()
        {
            IMessageInfo message = new MessageInfo();
            message.code = (int)MessageCodeType.Success;
            message.message = Utils.GetEnumDescription(MessageCodeType.Success);
            message.data = ProcessResponseData();

            return message;
            
        }

        private ResponseDataInfo ProcessResponseData()
        {
            //use postdata.data to process responseData
            if (postdata == null || postdata.data == null)
                return null;

            ResponseDataInfo responseData = new ResponseDataInfo();
            TbCompanyEntity entity = TbCompanyManager.Instance().GetModelByCache(postdata.data.companyid);

            if (entity == null)
                return null;


            responseData.logo = ConfigHelper.GetConfigString("WebsiteImageUrl") + entity.companyLogo;
            responseData.zhanweihao = entity.ZhanWeiH;
            responseData.companyname = entity.companyName;
            responseData.tele = entity.companyTele;
            responseData.summary = entity.companyMemo;
            responseData.location = entity.location;
            responseData.firstchar = entity.firstPingYinChar;
            return responseData;         
        }

        public class RequestDataInfo 
        {
            public int companyid { get; set; }
        }

        public class ResponseDataInfo
        {
            public string logo { get; set; }
            public string zhanweihao { get; set; }
            public string companyname { get; set; }
            public string tele { get; set; }
            public string summary { get; set; }
            public string location { get; set; }
            public string firstchar { get; set; }


        }


    }
}
